#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 2e5 + 10;
const LL mod = 1e9 + 7;

vector<int> div(vector<int> &A, int &b, int &r)
{
	vector<int> res;
	r = 0;
	for(int i = A.size() - 1; i >= 0; i--)
	{
		r = r * 10 + A[i];
		res.push_back(r / b);
		r %= b;
	}
	
	reverse(res.begin(), res.end());
	while(res.size() > 1 && res.back() == 0) res.pop_back();
	return res;
}

signed main ()
{
	cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
	
	int b;
	string a; cin >>a >>b;
	vector<int> A;
	for(int i = a.size() - 1; i >= 0; i--) A.push_back(a[i] - '0');
	
	int r = 0;
	auto res = div(A, b, r);
	for(int i = res.size() - 1; i >= 0; i--) cout <<res[i]; cout <<endl;
	cout <<r <<endl;
	
	return 0;
}